import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/views/Index' 
Vue.use(VueRouter)


const routes = [
  {
    path: '/index',
    name: 'Index',
    component: Index,
    meta:{title:"微志益"}
  },
  {
    path: '/indexDetail/:id',
    component: () => import(/* webpackChunkName: "package" */'@/views/Index/IndexDetail.vue'),
    meta:{title:"文章详情"}
  },
  {
    path: '/money',
    component: () => import(/* webpackChunkName: "package" */'@/views/Money.vue'),
    meta:{title:"捐赠钱款"}
  },
  {
    path: '/moneydetail/:id',
    component: () => import( /* webpackChunkName: "package" */'@/views/Money/Moneydetail.vue'),
    meta:{title:"捐赠详情"}
  },
  {
    path: '/startforum',
    component: () => import( /* webpackChunkName: "package" */'@/views/Forum/Startforum.vue'),
    meta:{title:"论坛添加"}
  },
  {
    path: '/goods',
    component: () => import(/* webpackChunkName: "package" */'@/views/Goods.vue'),
    meta:{title:"捐赠物资"}
  },
  {
    path: '/goodsdetail/:id',
    component: () => import(/* webpackChunkName: "package" */'@/views/Goods/GoodsDetail.vue'),
    meta:{title:"捐物详情"}
  },
  {
    path: '/needgoods',
    component: () => import(/* webpackChunkName: "package" */'@/views/Goods/Needgoods.vue'),
    meta:{title:"捐物详情"}
  },
  {
    path: '/find',
    component: () => import(/* webpackChunkName: "package" */'@/views/Find.vue'),
    meta:{title:"紧急寻人"}
  },
  {
    path: '/findDetail/:id',
    component: () => import(/* webpackChunkName: "package" */'@/views/Find/FindDetail.vue'),
    meta:{title:"寻人详情"}
  },
  {
    path: '/findxy',
    component: () => import(/* webpackChunkName: "package" */'@/views/Find/Findxy.vue'),
    meta:{title:"寻人须知"}
  },
  {
    path: '/startfind',
    component: () => import(/* webpackChunkName: "package" */'@/views/Find/Startfind.vue'),
    meta:{title:"发布寻人"}
  },
  {
    path: '/volunteer',
    component: () => import(/* webpackChunkName: "package" */'@/views/Volunteer.vue'),
    meta:{title:"志愿活动"}
  },
  {
    path: '/volunteerDetail/:id',
    component: () => import(/* webpackChunkName: "package" */'@/views/Volunteer/Volunteerdetail.vue'),
    meta:{title:"活动详情"}
  },
  {
    path: '/startvolunteer',
    component: () => import(/* webpackChunkName: "package" */'@/views/Volunteer/Startvolunteer.vue'),
    meta:{title:"发布活动"}
  },
  {
    path: '/login',
    component: () => import(/* webpackChunkName: "package" */'@/views/Login.vue'),
    meta:{title:"登录"}
  },
  {
    path:'/findpassword',
    component: () => import(/* webpackChunkName: "package" */'@/views/Login/Findpassword.vue'),
    meta:{title:"找回密码"}
  },
  {
    path: '/register',
    component: () => import(/* webpackChunkName: "package" */'@/views/Register.vue'),
    meta:{title:"注册"}
  },
  {
    path: '/personalcenter',
    component: () => import(/* webpackChunkName: "package" */'@/views/Personalcenter.vue'),
    meta:{title:"个人中心"}
  },
  {
    path: '/score',
    component: () => import(/* webpackChunkName: "package" */'@/views/Score.vue'),
    meta:{title:"礼品兑换"}
  },
  {
    path: '/forum',
    component: () => import(/* webpackChunkName: "package" */'@/views/Forum.vue'),
    meta:{title:"论坛文章"}
  },
  {
    path:"/404",
    component: () => import(/* webpackChunkName: "package" */'@/views/404.vue'),
    meta:{title:"页面走丢了~"}
  },
  {
    path:"/",
    redirect:'/index'
  },
  {path: '*', 
  redirect: '/404',
  meta:{title:"页面走丢了~"}
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// 避免冲突
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
} 
export default router
